<link rel="stylesheet" href="/static/index/css/drop.css">

<div class="widthFullScreen comHeader">
    <div class="wdSafe">
        <img src="https://img.qikuai100.com/custorm.png" class="pull-left headerCustPic" alt="">
        <div class="pull-left cust_tel">客服电话：173-4303-0506</div>
        <a href="/" class="pull-left return_back">返回首页</a>
        <!-- <a href="" class="pull-right ruzhu">代办公司入驻</a> -->
        <ul class="pull-right list_header_com" id="unLoginEd">
            <li>
                <a href="/user/login">登录</a>
            </li>
            <li>
                <a href="/user/reg">注册</a>
            </li>
        </ul>
        <ul class="pull-right list_header_com" id="logindEd" >
            <li>
                <a href="javascript:;">奇快企服欢迎,&nbsp;<span id="userNameBox">admin</span>&nbsp;回来</a>
            </li>
            <li>
                <a href="/users/index">查看<span class="colorMain">我的订单</span></a>
            </li>
            <li onclick="loginOut()">
                <a href="javascript:;">退出</a>
            </li>
        </ul>
    </div>
</div>


<script type="text/javascript">
    var baseUrl = 'https://api.qikuai100.com/',
        uid = localStorage.getItem("uid");
   
    /**
    * 登录判断
    */
    // 登录验证
    function initLogin() {
        $.ajax({
            type: "POST",
            url: baseUrl + "api/auth/checklogin",
            data: {
                "uid": uid
            },
            success: function(result) {
                // console.log(result)
                if (result.ret == 0) {
                    if(result.data.status == '1'){
                        $('#unLoginEd').hide();
                        $('#logindEd').show();
                        var name = localStorage.getItem("name");
                        $('#userNameBox').html(name);
                    }else{
                        $('#unLoginEd').show();
                        $('#logindEd').hide();
                    }
                }else{
                    console.log("333")
                    $('#unLoginEd').show();
                    $('#logindEd').hide();
                }
            }
        });
    }
    initLogin();

    /**
    * 退出
    */
    function loginOut(){
        $.ajax({
            type: "POST",
            url: baseUrl + "api/auth/logout",
            data: {
                "uid": uid
            },
            success: function(result) {
                if(result.ret == 0) {
                    localStorage.clear();
                    layer.msg("退出登录成功");
                    setTimeout(function(){
                        window.location.href = '/index/index';
                    }, 1000);
                }else{
                    layer.msg(result.res_info);
                }
            }
        });
    }
</script>